import { Session } from '/@/utils/storage';
export function useJump(router: any) {
	const toAreaDigital = (row: any, type: any) => {
		// let listeners = Session.get('listeners')
		// let obj = listeners?(typeof listeners=='string'?JSON.parse(listeners):listeners):{}
		// obj[row.paramMap?.declareId] = row.paramMap.listeners
		// Session.set('listeners',JSON.stringify(obj))
		//区县
		let pageTape = '';
		router.push({
			path: row.routeConfig.routeUrl,
			query: {
				// tagsViewName:'详情',
				pageTape: type,
				id: row.paramMap?.declareId,
				title: '数字化应用备案详情',
				nodeId: row.nodeId,
				taskId: row.taskId,
				processInstanceId: row.processInstanceId,
			},
		});
	};
	//三张清单 type => 1 已办
	const toThreeList = (row: any, type: any) => {
		if (type == 1) {
			router.push({
				path: row.routeConfig.routeUrl,
				query: {
					operateType: 'audit',
					threeListId: row.paramMap?.businessKey,
					processInstanceId: row.processInstanceId,
					processStatus: '',
				},
			});
		} else {
			router.push({
				path: row.routeConfig.routeUrl,
				query: {
					operateType: 'audit',
					threeListId: row.paramMap?.businessKey,
					processInstanceId: row.processInstanceId,
					processStatus: '1',
				},
			});
		}

		// router.push({
		// 	path: row.routeConfig.routeUrl,
		// 	query: {
		// 		threeListId: row.paramMap?.businessKey,
		// 		pageFrom: type == 1 ? 'finish' : 'schedule',
		// 		operateType: 'view',
		// 		nodeId: row.nodeId,
		// 		taskId: row.taskId,
		// 		processInstanceId: row.processInstanceId,
		// 	},
		// });
	};
	//专家审核 type => 1 已办
	const toExpertDetail = (row: any, type: any) => {
		if (type == 1) {
			router.push({
				path: row.routeConfig.routeUrl,
				query: {
					expertInfoId: row.paramMap?.expertInfoId,
					processInstanceId: row.processInstanceId,
					operateType: 'view',
					status: '',
					processStatus: '',
				},
			});
		} else {
			router.push({
				path: row.routeConfig.routeUrl,
				query: {
					expertInfoId: row.paramMap?.expertInfoId,
					processInstanceId: row.processInstanceId,
					operateType: 'approve',
					processStatus: '1',
				},
			});
		}
	};
	//资料修改 type => 1 已办
	const toInfoDetail = (row: any, type: any) => {
		router.push({
			path: row.routeConfig.routeUrl,
			query: {
				businessKey: row.paramMap?.businessKey,
				businessType: row.paramMap?.businessType,
				pageFrom: type == 1 ? 'finish' : 'schedule',
				nodeId: row.nodeId,
				taskId: row.taskId,
				processStatus: type == 1 ? '' : '1',
				processInstanceId: row.processInstanceId,
				dataModifyId: row.paramMap?.businessKey,
			},
		});
	};
	//数字化应用申报
	const toNumDetail = (row: any, status: any) => {
		router.push({
			path: row.routeConfig.routeUrl,
			query: {
				title: '数字化应用申报审核',
				status: status,
				isStatus: status,
				pageTap: 'numDecs',
				appCode: row.paramMap?.appCode, //保存
				instanceId: row.processInstanceId,

				id: row.paramMap?.id,
				nodeId: row.nodeId,
				taskId: row.taskId,
				processInstanceId: row.processInstanceId,
			},
		});
	};
	//数字化应用实施
	const toAppDetail = (row: any, status: any) => {
		let id = '';
		let reallyId = null;
		let pageTap = row.paramMap.pageTap;
		console.log(pageTap, 'pageTap');

		let title = '';
		if (row.paramMap.pageTap == 'impDec') {
			title = '实施方案申报';
			id = row.paramMap.id;
		}
		if (!row.paramMap.pageTap) {
			title = '实施方案审核';
			id = row.paramMap.id;
			pageTap = 'impDecs';
		}
		if (row.paramMap.pageTap == 'appChang') {
			title = '应用变更';
			id = row.paramMap.impId;
			reallyId = row.paramMap.id;
		}
		if (row.paramMap.pageTap == 'appChangs') {
			title = '应用变更审核';
			id = row.paramMap.impId;
			reallyId = row.paramMap.dataId;
		}
		if (row.paramMap.pageTap == 'implTer') {
			title = '应用实施终止';
			id = row.paramMap.impId;
			reallyId = row.paramMap.id;
		}
		if (row.paramMap.pageTap == 'implTers') {
			title = '应用实施终止审核';
			id = row.paramMap.impId;
			reallyId = row.paramMap.dataId;
		}

		router.push({
			path: row.routeConfig.routeUrl,
			query: {
				title: title,
				status: status,
				pageTap: pageTap,
				appCode: row.paramMap?.appCode, //保存

				id: id,
				reallyId: reallyId,
				nodeId: row.nodeId,
				taskId: row.taskId,
				processInstanceId: row.processInstanceId,
			},
		});
	};
	const toDetail = (row: any) => {
		router.push({
			path: row.routeConfig.routeUrl,
			query: {
				id: row.paramMap?.declareId,
				nodeId: row.nodeId,
				taskId: row.taskId,
				pageFrom: 'schedule',
				processInstanceId: row.processInstanceId,
			},
		});
	};
	return {
		toAreaDigital,
		toThreeList,
		toDetail,
		toNumDetail,
		toAppDetail,
		toInfoDetail,
		toExpertDetail,
	};
}
